home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utilsys / rss14gmd.lha / RSys_1.4gmd / Asm / RSysTrap.asm < prev   
Assembly Source File  |  1996-04-08  |  2KB  |  88 lines

  1. ;GMD        CSECT __MERGED
  2.         CSECT __ZZZZ
  3.  
  4. ;          far       code
  5. ;          public   _geta4
  6. ;          public   __trapexception
  7. ;                public   __initfpu
  8.  
  9.           XDEF   __trapexception
  10.                  XDEF   __initfpu
  11.  
  12.              xref     __oldtrap
  13.             xref     __traphandler
  14.           xref   _geta4
  15.  
  16. DEFTRAP MACRO                        ;&signalnumber
  17.           cmp.w      \1,d0                  ;compare trap number
  18.           beq       _deftrap            ;branch to default traphandler
  19.           ENDM
  20.  
  21. MYTRAP  MACRO                        ;&signalnumber
  22.           cmp.w      \1,d0                  ;compare trap number
  23.           beq       _mytrap            ;branch to own traphandler
  24.           ENDM
  25.  
  26. __trapexception:
  27.           movem.l  d0/a4,-(sp)            ;need some registers
  28.           jsr       _geta4             ;set up a4
  29.           move.l   8(sp),d0            ;get trap number
  30.           DEFTRAP  #1                ;define the traphandler
  31.           DEFTRAP  #2
  32.           DEFTRAP  #3
  33.           MYTRAP   #4
  34.           MYTRAP   #5
  35.           MYTRAP   #6
  36.           DEFTRAP  #7
  37.           MYTRAP   #8
  38.           MYTRAP   #9
  39.           DEFTRAP  #10
  40.           DEFTRAP  #11
  41.           MYTRAP   #12
  42.           DEFTRAP  #13
  43.           DEFTRAP  #14
  44.           DEFTRAP  #15
  45.           MYTRAP   #16
  46.  
  47. _deftrap:
  48.           move.l   4(sp),d0                ;get a4 for later
  49.           move.l   __oldtrap,4(sp)     ;get regular handler
  50.           move.l   d0,a4                    ;set real a4 value
  51.           move.l   (sp)+,d0                ;restore d0 contents
  52.           rte                                 ;jump to it
  53.  
  54. _mytrap:
  55.           move.l   a0,-(sp)                ;save a0
  56.           move.l   usp,a0                 ;get user stack pointer
  57.           move.l   18(sp),-(a0)         ;save old pc
  58.           move.w   14(sp),-(a0)         ;save old sr
  59.           movem.l  d0-d7/a0-a6,-(a0)    ;save old registers
  60.           movem.l  (sp)+,d1/d2/d3        ;restore d0/a0/a4
  61.           move.l   d1,(a0)                ;set d0
  62.           move.l   d2,32(a0)             ;set a0
  63.           move.l   d3,48(a0)             ;set a4
  64.           move.l   d0,-(a0)                ;pass trap number on stack
  65.           lea       _conttrap,a1         ;get return in case they want to continue
  66.           move.l   a1,-(a0)                ;set return address
  67.           move.l   a0,usp                 ;set new user stack pointer
  68.           lea       __traphandler,a0    ;get trap handler
  69.           move.l   a0,6(sp)                ;modify rte address
  70.           addq      #4,sp                    ;remove trap #
  71.           rte                                 ;go and do the handler
  72.  
  73. _conttrap:
  74.           add.w      #4,sp                    ;pop arg
  75.           movem.l  (sp)+,d0-d7/a0-a6    ;restore old registers
  76.           move.w   (sp)+,ccr             ;restore old condition codes
  77.           rts                                 ;and continue where we left off
  78.  
  79. __initfpu:
  80. ;          mc68881
  81.  
  82.           fmove.l  FPCR,d0
  83.           or.w      #$1400,d0
  84.           fmove.l  d0,FPCR
  85.             rts
  86.  
  87.         END
  88.